﻿using FluentNHibernate.Mapping;
using MadMediaManager.Core.Interfaces.Domain;

namespace MadMediaManager.DataAccess.Mappings
{
    public class BaseMapping<T, TId> : ClassMap<T> where T : IEntity<TId>, IVersionable<byte[]>, IDeletable
    {
        public BaseMapping()
        {
            Id(c => c.EntityId, "Id")
                .GeneratedBy.Assigned()
                .Length(255);
            Map(c => c.IsDeleted)
                .Not.Nullable();
            Version(c => c.RowVersion)
                .CustomSqlType("rowversion")
                .Nullable()
                .Generated.Always();
        }
    }
}
